/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.yami.shop.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yami.shop.bean.dto.OrderRefundDto;
import com.yami.shop.bean.model.Order;
import com.yami.shop.bean.model.Sku;
import com.yami.shop.bean.model.StockBillLog;
import com.yami.shop.bean.model.StockBillLogItem;
import com.yami.shop.bean.param.ProductParam;
import com.yami.shop.common.util.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 出入库明细
 *
 * @author LGH
 * @date 2021-09-09 13:11:15
 */
public interface StockBillLogService extends IService<StockBillLog> {

    /**
     * 保存出入库明细信息
     * @param stockBillLog
     */
    void saveInfo(StockBillLog stockBillLog);

    /**
     * 分页获取出入库明细信息
     * @param page
     * @param stockBillLog
     * @return
     */
    IPage<StockBillLog> pageByParams(PageParam<StockBillLog> page, StockBillLog stockBillLog);

    /**
     * 更新出入库明细信息
     * @param stockBillLog
     */
    void updateInfo(StockBillLog stockBillLog);

    /**
     * 导出出入库明细信息
     * @param stockBillLog
     * @param response
     */
    void exportStockBillLog(StockBillLog stockBillLog, HttpServletResponse response);

    /**
     * 作废出入库明细单
     * @param shopId
     * @param stockBillLogId
     */
    void voided(Long shopId, Long stockBillLogId);

    /**
     * 根据id获取
     * @param stockBillLogId
     * @return
     */
    StockBillLog getByStockBillLogId(Long stockBillLogId);

    /**
     * 库存初始化
     * @param stockBillLog
     * @param skuList
     */
    void initialize(StockBillLog stockBillLog, List<Sku> skuList);

    /**
     * 库存查询
     * @param page
     * @param productParam
     * @return
     */
    IPage<StockBillLogItem> inquire(PageParam<StockBillLog> page, ProductParam productParam);

    /**
     * 生成出入库明细(单品)
     * @param orderNumber
     * @param prodId
     * @param skuId
     * @param changeStocks
     * @param stockBillType
     * @param stockType
     */
    void generateStockLogBySkuInfo(String orderNumber, Long prodId, Long skuId, Integer changeStocks, Integer stockBillType, Integer stockType);

    /**
     * 根据订单生成出入库明细
     * @param orders
     * @param stockBillType
     * @param stockType
     */
    void generateStockLogOfOrderList(List<Order> orders, Integer stockBillType, Integer stockType);

    /**
     * 根据退款订单生成出入库明细
     * @param orderRefundDto
     * @param stockBillType
     * @param stockType
     */
    void generateStockLogOfRefundOrder(OrderRefundDto orderRefundDto, Integer stockBillType, Integer stockType);

    /**
     * 分页获取采购信息
     * @param page
     * @param stockBillLog
     * @return
     */
    IPage<StockBillLog> purchasePage(PageParam<StockBillLog> page, StockBillLog stockBillLog);

    /**
     * 根据id获取出入库明细信息
     * @param stockBillLogId
     * @return
     */
    StockBillLog purchaseInfo(Long stockBillLogId);

    /**
     * 生成编辑出入库记录
     * @param stockBillLog
     * @param skuList
     */
    void generateStockLogOfEditInfo(StockBillLog stockBillLog, List<Sku> skuList);

    /**
     * 根据盘点信息生成出入库记录
     * @param stockBillLog
     * @param skuList
     */
    void generateStockLogOfTakeStock(StockBillLog stockBillLog, List<Sku> skuList);

    /**
     * 删除没有出入库商品项的出入库记录
     */
    void removeEmptyLog();
}
